<?php

include_once("./vendor/autoload.php");

use YouBaoLian\YouBaoLian;

$youBaoLian = new YouBaoLian([
    'logsDir' => './logs',
    'appId' => 'appId',
    'gateway' => 'gateway',
    'publicKey' => 'publicKey',
    'privateKey' => 'privateKey',
    'encryptKey' => 'encryptKey'
]);

//城市编码
$cityCode = '510100';
//报价配置ID
$configId = 2919958;
//保司ID
$supplierId = 9803;

//报价单ID
$priceItemId = 9524579;


//续保查询
if (1) {

    $franeNo = 'LVZUR31B8JC101915';
    $licenseNo = '川A24X3Y';
    $ownerIdCard = '510111195311173230';
    $engineNo = '18021222';

    $renewalRequest = new \YouBaoLian\Application\Request\VehicleModelRequest();
    $renewalRequest->setCityCode($cityCode);
    $renewalRequest->setConfigId($configId);
    $renewalRequest->setEngineNo($engineNo);
    $renewalRequest->setFrameNo($franeNo);
    $renewalRequest->setLicenseNo($licenseNo);
    $renewalRequest->setSupplierId($supplierId);
    $renewalRequest->setOwnerIDCard($ownerIdCard);

    $response = $youBaoLian->renewal($renewalRequest);
//    var_dump($response->isSuccess());
    var_dump($response->getRenewalInfo());
    var_dump($response->getRenewalDtoList());
//    var_dump($response->getSign());
//    var_dump($response->getError());
//    var_dump($response->getCode());

}

//车险查询
if (0) {
    $brand = '大众汽车牌SVW71416CL';
    $engineNo = 'A07114';
    $firstRegisterDate = '2015-04-30';
    $licenseNo = '川A0M2M5';
    $vehicleFrameNo = 'LSVCC2BM1FN016345';

    $vehicleModelRequest = new \YouBaoLian\Application\Request\VehicleModelRequest();
    $vehicleModelRequest->setBrand($brand);
    $vehicleModelRequest->setCityCode($cityCode);
    $vehicleModelRequest->setConfigId($configId);
    $vehicleModelRequest->setEngineNo($engineNo);
    $vehicleModelRequest->setFirstRegisterDate($firstRegisterDate);
    $vehicleModelRequest->setLicenseNo($licenseNo);
    $vehicleModelRequest->setFrameNo($vehicleFrameNo);

    $response = $youBaoLian->model($vehicleModelRequest);

    var_dump($response->getModelList());
    exit;
}

//非车产品查询
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleNoCarProductRequest();
    $request->setSupplierId($supplierId);
    $request->setConfigId($configId);
    $request->setOwnerShipAttribute(1);
    $request->setUsageAttribute(1);
    $request->setSeats(5);
    $request->setCityCode($cityCode);
    $request->setVehicleTonnages(0);

    $response = $youBaoLian->noCarProduct($request);

    var_dump($response->getInsuredWithCarProduct());
    var_dump($response->getProductPlans());
    var_dump($response->getProductTypes());


}

//保费计算
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleQuoteRequest();

    $request->setCiBeginDate('2022-04-20 00:00:00');
    $request->setBiBeginDate('2022-04-20 00:00:00');
    $request->setCityCode($configId);
    $request->setSupplierId($supplierId);
    $request->setConfigId($configId);

    $person = new \YouBaoLian\Application\Info\PersonInfo();
    $person->setName('');
    $person->setMobile('');
    $person->setIdCard('');
    $person->setIdType('');
    $person->setAddress('');
    $person->setIdCardStartDate('2000-01-01');
    $person->setIdCardEndDate('2099-12-31');
    //关系人
    $request->setApplicantInfo($person);
    $request->setInsuredInfo($person);
    $request->setOwnerInfo($person);
    //车辆信息
    $carInfo = new \YouBaoLian\Application\Info\CarInfo();
    $carInfo->setLicenseNo('');
    $carInfo->setFrameNo('');
    $carInfo->setEngineNo('');
    $carInfo->setAutoModelName('');
    $carInfo->setOwnershipAttribute(1);
    $carInfo->setDefaultModelCode('');
    $carInfo->setDefaultModelName('');
    $carInfo->setEnergyType('');
    $carInfo->setExhaustCapability('');
    $carInfo->setFirstRegisterDate('');
    $carInfo->setVehicleTonnages('');
    $carInfo->setWholeWeight('');
    $carInfo->setCarPrice(0.00);
    $carInfo->setCarPriceWithOutTax(0.00);
    $carInfo->setIsTrans(1);
    $carInfo->setTransDate('');
    $carInfo->setIssueDate('');
    $carInfo->setLicenseColorCode('1');
    $carInfo->setPlateTypeCode('K31');
    $carInfo->setPower(0);
    $carInfo->setSeats(5);
    $carInfo->setUsageAttribute(1);
    $carInfo->setVehicleClassCode('1');
    $carInfo->setDrivingLicenseModel('');
    $carInfo->setVehicleSrcCertiDate('');
    $carInfo->setVehicleSrcCertiType('');

    $request->setCarInfo($carInfo);
    //车船税信息
    $carTaxInfo = new \YouBaoLian\Application\Info\CarTaxInfo();

    $carTaxInfo->setVvTaxState('1');
    $carTaxInfo->setBaseTaxation('');
    $carTaxInfo->setFreeRate('');
    $carTaxInfo->setTaxRelief('');
    $carTaxInfo->setReductionText('');
    $carTaxInfo->setRelifReason('');
    $carTaxInfo->setTaxDep('');
    $carTaxInfo->setTaxDepCode('');
    $carTaxInfo->setTaxDocumentDate('');
    $carTaxInfo->setTaxPaidAreaCode('');
    $carTaxInfo->setTaxNo('');

    $request->setCarTaxInfo($carTaxInfo);

    //险种
    $coverageList = new \YouBaoLian\Application\Info\CoverageList();

    $coverageList->append('10501', '200000');
    $coverageList->append('10001', '60300');
    $request->setCoverageList($coverageList);
    //新能源汽车 投保附加自用充电桩
    $chargingPostList = new \YouBaoLian\Application\Info\ChargingPostList();
    $chargingPostList->append('1', '1', '1', '充电桩设备名称');
    $request->setChargingPostList($chargingPostList);

    //扩展信息
    $extInfo = new \YouBaoLian\Application\Info\ExtInfo();
    $extInfo->setCarCheckStatus('2');
    $request->setExtInfo($extInfo);

    //非车险信息
    $insProductPlansList = new \YouBaoLian\Application\Info\InsProductPlansList();
    $insProductPlansList->append('1', 'code', 'productCode', '1');
    $request->setInsProductPlans($insProductPlansList);

    //北京兼业从业人员
    $jianYeSalerInfo = new \YouBaoLian\Application\Info\ParergonSaleInfo();
    $jianYeSalerInfo->setName('name');
    $jianYeSalerInfo->setTelephone('123456789');
    $jianYeSalerInfo->setSalerSortNo('1');
    $jianYeSalerInfo->setPracticeCertificateNo('123123');
    $request->setJianYeSalerInfo($jianYeSalerInfo);

    //广东，深圳双录销售信息
    $saleInfo = new \YouBaoLian\Application\Info\SaleInfo();
    $request->setSaleInfo($saleInfo);

    $response = $youBaoLian->quote($request);

    var_dump($response->getPriceItemId());
    var_dump($response->getBiBeginDate());
    var_dump($response->getTotalPrice());


}

//上传影像接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleUploadImgRequest();
    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);

    $response = $youBaoLian->uploadImg($request);

    var_dump($response->getUploadUrl());
    var_dump($response->getData());

}

//特约查询接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleQuerySpecialRequest();

    $request->setPriceItemId($priceItemId);
    $request->setConfigId($configId);
    $request->setSupplierId($supplierId);

    $response = $youBaoLian->querySpecial($request);
    var_dump($response->getSupplierId());
    var_dump($response->getTotal());
    var_dump($response->getData());
}

//核保提交接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleSubmitUnderWriteRequest();
    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);

    $response = $youBaoLian->underwriting($request);

    var_dump($response->getCheckState());
    var_dump($response->getInsuredId());
    var_dump($response->getInsSpecialClause());
}

//核保ID
$insuredId = 99587;

//支付接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehiclePaymentRequest();

    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);

    $response = $youBaoLian->paying($request);

    var_dump($response->getBiSlipNo());
    var_dump($response->getCiSlipNo());
    var_dump($response->getLicenseNo());
    var_dump($response->getQrCodeImg());
    var_dump($response->getTotalPrice());
}

//短信发送接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleSendSmsCodeRequest();

    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);
    $request->setInsuredId($insuredId);

    $response = $youBaoLian->sendSmsCode($request);

    var_dump($response->isSendSuccess());
    var_dump($response->getVerifyCodeStatus());
    var_dump($response->getFailMessage());

}

//短信消费接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleVerifySmsCodeRequest();

    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);
    $request->setVerificationCode('123456');

    $response = $youBaoLian->verifySmsCode($request);

    var_dump($response->isSuccess());

}

//电子保单接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleElecPolicyRequest();
    $request->setConfigId($configId);
    $request->setInsuredId($insuredId);
    $request->setInsuranceType(10);
    $request->setPolicyNo('');

    $response = $youBaoLian->ePolicy($request);

    var_dump($response->getEPolicyLink());
    var_dump($response->getCiFlagLink());

}

//撤单接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleRevokeRequest();

    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);

    $response = $youBaoLian->revoke($request);

    var_dump($response->getStatus());
    var_dump($response->getInfo());
}

//报价单详情查询接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehiclePriceDetailRequest();

    $request->setConfigId($configId);
    $request->setPriceItemId($priceItemId);

    $response = $youBaoLian->priceDetail($request);

    var_dump($response->getTotalPremium());
    var_dump($response->getStatus());
    var_dump($response->getCiBeginDate());
    var_dump($response->getCoverageList());
}

//从业人员查询接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleQuerySalesPersonRequest();

    $request->setConfigId($configId);
    $request->setLicenseNo('');
    $request->setFrameNo('');
    $request->setSaleCode('');

    $response = $youBaoLian->querySalesPerson($request);

    var_dump($response->getSalerInfoList());

}

//查询报价单状态
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleQueryPriceStatusRequest();

    $request->setConfigId($configId);
    $request->setInsuredId($insuredId);

    $response = $youBaoLian->queryPriceStatus($request);

    var_dump($response->getLicenseNo());
    var_dump($response->getVehicleFrameNo());
    var_dump($response->getInsuredList());
    var_dump($response->getProductPlan());
}

//非车产品责任明细查询接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleNoCarProductDetailRequest();

    $request->setConfigId($configId);
    $request->setSupplierId($supplierId);
    $request->setProductCode('');
    $request->setProductType('');
    $request->setVersion('');
    $request->setPlanCode('');
    $request->setCityCode('');

    $response = $youBaoLian->noCarProductDetail($request);

    var_dump($response->getList());
}

//计算车辆实际价值接口
if (0) {
    $request = new \YouBaoLian\Application\Request\VehicleActualPriceRequest();

    $request->setConfigId($configId);
    $request->setStartDate('');
    $request->setEnrollDate('');
    $request->setSeatCount(5);
    $request->setTonNumber(0);
    $request->setPurchasePrice(0);
    $request->setCarKindCode('1');
    $request->setUseNatureCode('1');

    $response = $youBaoLian->actualPrice($request);

    var_dump($response->getActualValue());
    var_dump($response->getActualRate());
    var_dump($response->getActualValueMax());
    var_dump($response->getActualValueMin());
}

$string = '{"bizContent":"KNZ3ReaJcWLzP5Nm/5o0+AT07VnAdPcYTvAPBioItQGQ8u/2LFwapwxkWmf6BnZC1Pyxkt4FVz8kyHRbBihCmqVtUYh14zy7rJd8MvyBoq5lWM8AihABX9LvpK9siMuhe6/n8W6GTix9zWQ4BmjZ7zkfwCOhgCgxjkpGv4F88+x+IAJ9D2BvG+nZvxyAE36I+jRT4o+r6GCzCdAY0fNZTb6jj0JXP7r/hZQoFPVuW+s0hPGkJswE822vyJEDA5km01iJXiPW/DRQNzDAFz4511zIOI407oEh5/VwjiE87ozAzWGYSutBhEIuHssI/cke8Yz4J3gD9y/XDwaOBXVG2mgciOpGzSJSTnHMInB9MpCPKSCS94b7zDnz7LWv43BqobGLaw8NoEE1/EHdEGqkjmNH8GIYfXyifzruKQHSQi+nAnY7HATMwef7BUcWh7gMSMttYkAi4J7jDlGBuWXqbh9tCJNKQsMhykRHTo3I8jBdvUGXe/76sQNCn2IfFBCiDrLt4x3v2GhEzcmn9auMaR6rJf3m4pAzqyjJ5ZRIp0ZYKpsPYesHNO9xecAkirvyyUIn8jQN2cavktlIi6mmTaH/QE8HfvtPHyPS7GR7isd02qLVtVwxdmZnOu1wcHNY3d12eDcGsMCA9qecOP6J5Qz4gM0+Dh0lPT8QWfzIXsM3RuH/knvYpw8tJLcc5bZkWEKmI5hfOgzIRJQ0Gfqu3bL7/hnIjaoy/0KC2JAReP8CSYtK0ONl/c+mVBpnFosB+5WHlJYsFOttVO/TAQ6/gx0ORIkDwNvwgAXdIuKnfsbC1sNWzZBW6J/ktStgKZWOKIvruzR4Ae/Qv7hgO1tVY87lHYI9zP3mtHNEdwocy4q+UayrMcW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rGrA0pgBvC2oblZg7UXDudA95LY1Aoe1NCfFiUh0ZCVEYKwwClhMSChUnpZAs5m2fQq0EuXjHT9GGp17sg+F5gWIwpsUaJeMUUYP","code":0,"message":"success","requestId":"47ccdb0c7f34f2632487e5da057a33678d3dfdcb","responseTime":"2022-03-29 15:37:02","sign":"dxi6jLd7v3gheNPwTDadLIhV0LfcQOx06otWPIFNEWIcdm+1qZ5t4Yvs/Ivtw5rQjbQqN+FKX1ScBQeqyFMhmmX3ootnc9IO/hugQCn/iGzJgvwG4fX7PvCKI/B4cQTDN8thefY9474e0LZdPrZgFriRUnyI4d98C/EEcRBTeeqPGYClgH2008qn+vuIu8mJz9WEpIaJ0u98n/uSp7PacLCvYxSPWKbhYN/+lqzcfhDtkvwyalGJYiOtJRz0Z8MGN332YkFKpPSh8Hq9bOXUpxnvuh+CZeM2HetDqqbuqUk6QxSi9T7ktfU0XfCXJ8TJuv1/Fs65jMbb0H5Yv+rQLw=="}';

//人工核保结果回调接口
if (0) {
    $response = new \YouBaoLian\Application\Callback\VehicleManualUnderwritingRequest();

    $response->build($string);

    $youBaoLian->verifySign($response);

    var_dump($response->isSuccess());
    var_dump($response->getInfoList());

}

//支付成功回调接口
if (0) {
    $response = new \YouBaoLian\Application\Callback\VehiclePaymentRequest();

    $response->build($string);
    $youBaoLian->verifySign($response);

    var_dump($response->isSuccess());
    var_dump($response->getStatus());
    var_dump($response->getPayDate());
    var_dump($response->getPayAmount());
    var_dump($response->getInfoList());
}

//保单生效回调接口
if (0) {
    $response = new \YouBaoLian\Application\Callback\VehiclePolicyRequest();
    $response->build($string);
    $youBaoLian->verifySign($response);

    var_dump($response->isSuccess());
    var_dump($response->getBusinessId());
    var_dump($response->getInfoList());
}

